#define _CRT_SECURE_NO_WARNINGS 
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
ll a[20][20];
ll pos[4][2] = { 0,1,1,0,0,-1,-1,0 };
int main()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	ll n = 0;
	cin >> n;
	ll x = 1, y = 1, d = 0;
	for (ll i = 1; i <= n * n; i++)
	{
		a[x][y] = i;
		ll tx = x + pos[d][0], ty = y + pos[d][1];
		if (tx < 1 || tx > n || ty < 1 || ty > n || a[tx][ty]) d = (d + 1) % 4;
		x += pos[d][0];
		y += pos[d][1];
	}
	for (ll i = 1; i <= n; i++)
	{
		for (ll j = 1; j <= n; j++)
		{
			printf("%3lld", a[i][j]);
		}
		printf("\n");
	}
	return 0;
}